import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQml.Models 2.2
import QtQuick.Window 2.3
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4

import TreeViewModelPlugin 1.0

//          编码规范
//        id
//        属性声明
//        信号声明
//        JavaScript 函数
//        对象属性
//        子对象
//        状态
//        过渡

Rectangle {
    id:mainTreeView
    color: "transparent"

    width: 640
    height: 480

    TreeViewModel
    {
        id:treeViewModel
    }

    ItemSelectionModel {
        id: sel
        model: treeViewModel
    }

    TreeView {
        id: view
        anchors.fill: parent
        model: treeViewModel
        selection: sel
        itemDelegate: Text {
            color: "white"
            elide: styleData.elideMode
            text: styleData.value

            onTextChanged: {
                print(styleData.value)
                print(styleData.row)
            }
        }

        headerVisible:false
        rowDelegate:Rectangle{
            id: rowDel
            color: styleData.row % 2==0 ? "#434957" : "#313845"
            height: 20
        }

        TableViewColumn {
            title: "nameRole"
            role: "name"
            resizable: true
        }
        TableViewColumn {
            title: "iconRole"
            role: "icon"
            resizable: true
            horizontalAlignment : Text.AlignRight
            width: 70
        }
    }
}
